<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="f" uri="http://www.slim3.org/functions"%>

<%@ page import="jp.co.cos.ittrick.channel.model.ChannelModel" %>
<%@ page import="jp.co.cos.ittrick.channel.model.CategoryModel" %>
<%@ page import="jp.co.cos.ittrick.channel.model.ChapterModel" %>
<%@ page import="jp.co.cos.ittrick.channel.model.PageModel" %>
<%@ page import="java.util.List" %>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Channel管理</title>
	<link type="text/css" href="/css/admin/default.css" rel="stylesheet" />
	<link type="text/css" href="/css/admin/channel.css" rel="stylesheet" />
</head>
<body>
<%
ChannelModel channelModel = (ChannelModel)request.getAttribute("channela");
%>
<h1>Channel：   <%=channelModel.getName() %></h1>
<div id="actionbar">
	<a href="/admin/">HOMEへ</a>
	<a href="/admin/categoryNew?channel=${channel}">Category 登録</a>
</div>
<div id="content">
<%
List<CategoryModel> categoryList = channelModel.getCategoryModelListRef().getModelList();
for(CategoryModel categoryModel: categoryList) {
%>
	<div class="subtitle">
		<a href="/admin/categoryEdit?channel=${channel}&category=<%=categoryModel.getKeyString() %>">
			<%=categoryModel.getName() %>
		</a>
		<a id="actionlink1" href="/admin/categoryDelete?channel=${channel}&category=<%=categoryModel.getKeyString() %>" onclick="return confirm('delete OK?')">削除</a>
		<a id="actionlink1" href="/admin/chapterNew?channel=${channel}&category=<%=categoryModel.getKeyString() %>">Chapter追加</a>
	</div>

	<%
	List<ChapterModel> chapterList = categoryModel.getChapterModelListRef().getModelList();
	for(ChapterModel chapterModel: chapterList) {
	%>
	<div class="navimenu">
		<ul class="catemenu">
		<li class="navi">
			<a href="/admin/chapterEdit?channel=${channel}&category=<%=categoryModel.getKeyString() %>&chapter=<%=chapterModel.getKeyString() %>">
				<%=chapterModel.getName() %>
			</a>
			<a href="/admin/chapterPublic?channel=${channel}&chapter=<%=chapterModel.getKeyString() %>">
			<%
			if(chapterModel.getPublicFlg() != null && chapterModel.getPublicFlg()) {
			%>
			<img id="publicImages" width="15px" src="/images/admin/btn_checkbox_checked.png" />
			<%}else { %>
			<img id="publicImages" width="15px" src="/images/admin/btn_checkbox_default_over.png" />
			<%} %>
			</a>
			<a id="actionlink1" href="/admin/pageNew?channel=${channel}&chapter=<%=chapterModel.getKeyString() %>">Page追加</a>
			<a id="actionlink1" href="/admin/chapterDelete?channel=${channel}&chapter=<%=chapterModel.getKeyString() %>" onclick="return confirm('delete OK?')">削除</a>
		</li>

		<%
		List<PageModel> pageList = chapterModel.getPageModelListRef().getModelList();
		for(PageModel pageModel: pageList) {
		%>
		<li class="info">
			<a href="/admin/pageEdit?channel=${channel}&chapter=<%=chapterModel.getKeyString() %>&page=<%=pageModel.getKeyString() %>">
				<%=pageModel.getName() %>
			</a>
			<a href="/admin/pagePublic?channel=${channel}&page=<%=pageModel.getKeyString() %>">
			<%
			if(pageModel.getPublicFlg() != null && pageModel.getPublicFlg()) {
			%>
			<img id="publicImages" width="15px" src="/images/admin/btn_checkbox_checked.png" />
			<%}else { %>
			<img id="publicImages" width="15px" src="/images/admin/btn_checkbox_default_over.png" />
			<%} %>
			</a>
			<a id="actionlink1" href="/admin/pageDelete?channel=${channel}&page=<%=pageModel.getKeyString() %>" onclick="return confirm('delete OK?')">削除</a>
		</li>
		<%} %>
		</ul>
	</div>
	<%} %>
<%} %>
</div>
</body>
</html>